Skip to content

Continue work branches by merging their base before the agent runs - #358

Closed
n0rpan wants to merge 16 commits into
mainfrom
agent/333-work-continue
Closed

n0rpan wants to merge 16 commits into
mainfrom
agent/333-work-continue

Conversation

@n0rpan

@n0rpan n0rpan commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Delivers step 2 of #333, stacked on #336. T2.

Continuing a retained task branch first merges its base with a normal git merge. Unfinished conflicts stay in progress and reach the agent with both MERGE_HEAD and the newly captured base commit; the agent is asked to finish the old merge and integrate the current base. Branch/worktree identity and base ancestry are checked after each agent attempt, so aborted merges, unresolved conflicts and branch switches cannot report green.

Acceptance commands come from the captured base commit. Nothing resets, stashes, rebases or force-pushes retained work.

Validation at b7cfc06, including the latest #336 review fixes and a normal main merge: 184 touched-crate tests pass, plus full-workspace fmt, strict all-target clippy and four unchanged scans. Tests use real bwrap, a fake engine and local bare repositories; the old-pending-merge/new-base regression failed before its fix.

@n0rpan
n0rpan marked this pull request as ready for review November 15, 2026 15:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T15:53:38.164381Z c86fa8b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c86fa8b9bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oxa/oxa-work/src/tree.rs Resolved
@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head c86fa8b (O-241; the orchestrator adjudicates and enqueues).

I found one minor (P3) problem and nothing that blocks this PR.

P3: a resumed merge can be blocked if the base has moved on (oxa/oxa-work/src/tree.rs:25-28 together with :69-75 and :114-118). Each run looks up the base's current commit again. When a merge is left unfinished, the agent is asked to finish that same merge, which still points at the base commit from the earlier run. If main gains a commit between the two runs:

  1. The agent resolves and commits the old merge.
  2. The check that the base is merged then fails against the newer base commit.
  3. The task is reported blocked even though the work is correct.

Nothing is lost: the next run merges the newer base. But that resumed run is wasted, and the prompt's "merge in progress from base main" names main without saying it is an older commit. A fix would be to check against the commit the merge is actually using, or to tell the agent about the newer base.

The rest checks out:

  • Security: git merge runs outside the sandbox, but the sandbox already keeps the task's git hooks and config read-only, so it doesn't open a hook path. No checks are weakened, and the tests use only example.invalid addresses and placeholder paths.
  • Acceptance commands: they are read from the captured base commit, so a task branch can't replace them.
  • Tests: the new tests check the new behaviour and would fail without it, because the old code refused any existing branch or receipt. The removed "already exists" test was replaced by the "checked out elsewhere" test.

TIER: T2
VERDICT: CLEAR

🤖 Generated with Claude Code (oxa review lane)

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the first-pass P3 as well as the matching automated P2: pending-merge handoffs now include both commit IDs and the explicit follow-up merge of the captured current base. The new real-sandbox regression failed before the fix and passes now; all 164 touched-crate tests and strict clippy are green.

@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head d053910 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • oxa/oxa-work/src/tree.rs:74 (resuming an older merge after main moves on): FIXED. When a merge is still in progress, merge_prompt (tree.rs:21-24) now gives the agent the old pending commit and the newly captured base commit. It tells the agent to run git merge --no-edit <base> after finishing the old merge. ensure_merged checks against that same captured base, and the test resumed_old_merge_is_told_to_integrate_the_newly_captured_base covers this case.

New findings
I found no concrete defects. What I checked:

  • Receipt check: check_receipt compares the same non-canonical path that gets written into the receipt, so the two always match.
  • Agent errors: if the agent fails, the merge and branch checks still run first, so an agent error cannot report a green result on an unmerged branch.
  • Acceptance commands: they are now read from the captured base commit. For new branches that is the same source as before, so nothing is weakened.
  • Security and data: no scanner, sandbox or permission change. No secrets; the tests use example.invalid.

TIER: T2
VERDICT: CLEAR

🤖 Generated with Claude Code (oxa review lane)

@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head 6c24b5f (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • tree.rs:74 (resuming an older merge after main moves on): FIXED. When a run resumes a retained merge, merge_prompt (oxa/oxa-work/src/tree.rs:21-24) now gives the agent both the merge's own commit (MERGE_HEAD) and the newly captured base. It also tells the agent to run git merge --no-edit <base> after finishing the merge. ensure_merged checks against that same captured base. The new test resumed_old_merge_is_told_to_integrate_the_newly_captured_base covers this case: it checks that the prompt contains both commits and that the new base ends up in agent/test.

New findings
I found no concrete defects to report.

  • Merge checks: ensure_merged runs after both the first agent run and the repair run, so an aborted merge, an unresolved merge or a switched branch is reported as blocked.
  • Acceptance commands: they are read from the captured base commit (done_from_base), so a task branch can't weaken its own acceptance checks.
  • Retained receipts: a receipt is now reused instead of refused, but only after check_receipt confirms its ID, branch and worktree match the task.
  • Safety and data: nothing weakens the sandbox, a scanner or a permission, and the test fixtures use only example.invalid addresses.

TIER: T2
VERDICT: CLEAR

🤖 Generated with Claude Code (oxa review lane)

@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head b7cfc06 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • tree.rs:74 (resuming an old merge after main has moved on): FIXED. merge_prompt (tree.rs:21-24) now tells the agent which base the retained merge came from and the new base for this run. It also tells the agent to run git merge --no-edit <new base> after finishing the retained merge. The test resumed_old_merge_is_told_to_integrate_the_newly_captured_base in work_continue.rs covers this, and ensure_merged still blocks if the agent doesn't do it.

New findings

  • P3, oxa/oxa-work/src/lib.rs (~line 216): ensure_merged runs before the first agent's result is checked. If the agent fails while resolving a merge (for example the model is unavailable or the child crashes), the receipt says "merge remains in progress" or "base is not merged" instead of the agent's error. Successful runs aren't affected, but the cause of the failure is lost from the receipt. The same happens after the repair run (~line 228).

I found nothing that weakens a scanner, the sandbox, permissions or a budget, and no secrets or personal paths. Acceptance commands still come from the base commit, so a task branch can't change its own checks. Fresh branches behave the same as before.

TIER: T2
VERDICT: CLEAR

🤖 Generated with Claude Code (oxa review lane)

@n0rpan
n0rpan marked this pull request as draft November 15, 2026 21:13
@n0rpan
n0rpan changed the base branch from agent/333-work-task-runner to main November 15, 2026 21:31

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by the small main-based re-cut #678 at 72bf8d1, following the #331 series-first decision. The P3 at 6898954148 is fixed there: worker, merge and acceptance errors are collected together; the real missing-model + unfinished-merge regression fails with the old early return and passes with both causes retained. The older-base handoff fix remains covered. #678 also preserves merged #336’s trust/Git/receipt protections and puts automatic merges behind the real sandbox. All 287 touched tests/62 runner cases, strict checks and unchanged scans pass. Closing this stale stacked draft; no branch history is rewritten.

@n0rpan n0rpan closed this Nov 16, 2026
@oxa-orchestrator
oxa-orchestrator Bot deleted the agent/333-work-continue branch November 17, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant